package com.sky.controller;


import com.sky.dto.UserLoginDTO;
import com.sky.entity.User;
import com.sky.properties.JwtProperties;
import com.sky.result.Result;
import com.sky.service.ClazzService;
import com.sky.service.UserService;
import com.sky.vo.UserLoginVO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author LiZhiHan
 */
 @Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    ClazzService clazzService;
    private final UserService userService;

    private final JwtProperties jwtProperties;

    /**
     * 用户登录
     */
    @PostMapping("/login")
    @ApiOperation("用户登录")
    public Result<UserLoginVO> login(@RequestBody UserLoginDTO userLoginDTO){
        log.info("微信登录:{}",userLoginDTO);
        UserLoginVO user = userService.wxLogin(userLoginDTO);
        return Result.success(user);
    }
    @PostMapping("/join")
    public Result join(User user){
        log.info("加入班级:{}",user);
        userService.updateById(user);
        return Result.success();
    }
    @GetMapping("/get")
    public Result<User> get(User user){
        log.info("查询:{}",user);
        return Result.success(userService.getById(user.getId()));
    }
    @PutMapping("/update")
    public Result update(User user){
        log.info("更新:{}",user);
        userService.updateById(user);
        return Result.success();
    }
    @PutMapping("/displayGrade")
    public Result displayGrade(User user){
        log.info("是否显示:{}",user);
        userService.updateById(user);
        return Result.success();
    }




}
